package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FArray;

public class REMOVEARRAY extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 3)
      return Primitive.ERROR_VALUE;
    Object localObject1 = paramArrayOfObject[0];
    Object localObject2 = paramArrayOfObject[1];
    Object localObject3 = paramArrayOfObject[2];
    if ((!(localObject1 instanceof FArray)) || (!(localObject3 instanceof Integer)) || (!(localObject2 instanceof Integer)))
      return Primitive.ERROR_VALUE;
    FArray localFArray = (FArray)localObject1;
    int i = Integer.parseInt(localObject2.toString());
    int j = Integer.parseInt(localObject3.toString());
    return splice(localFArray, i, j);
  }

  private FArray splice(FArray paramFArray, int paramInt1, int paramInt2)
  {
    FArray localFArray = new FArray();
    if (paramInt1 < 1)
      paramInt1 = 1;
    if (paramInt2 < 0)
      paramInt2 = 0;
    for (int i = 0; i < paramInt1 - 1; ++i)
      localFArray.add(paramFArray.elementAt(i));
    for (i = paramInt1 + paramInt2 - 1; i < paramFArray.length(); ++i)
      localFArray.add(paramFArray.elementAt(i));
    return localFArray;
  }

  public Function.Type getType()
  {
    return Function.ARRAY;
  }

  public String getCN()
  {
    return "REMOVEARRAY(array, start, deleteCount):从数组array中删除从第start个元素开始的deleteCount个数组元素，并返回删除后的数组。\n示例：\nREMOVEARRAY([3, 4, 4, 2, 6, 7, 87], 4, 2)返回[3, 4, 4, 7, 87].\n";
  }

  public String getEN()
  {
    return "";
  }
}